﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using RecruitmentSystem.Common;
using RecruitmentSystem.Business;

public partial class StudentManagement_ChangePwd : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btn_SureChange_Click(object sender, EventArgs e)
    {
        if (txtOldPassword.Text.Trim() != "" && txtNewPassword.Text.Trim() != "" && txtConfirmPassword.Text.Trim() != "")
        {
            if (txtConfirmPassword.Text != txtNewPassword.Text)
            {
                Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "pwdwarning", "<script type='text/javascript'>alert('两次输入的密码不一致！');</script>");
                return;
            }
            else
            {

                AccountManager am = new AccountManager();
                bool ischange = am.ChangePassword(txtNewPassword.Text, txtOldPassword.Text, User.Identity.Name, UserType.PersonalUser);
                if (ischange)
                {
                    Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "changesuccess", "<script type='text/javascript'>alert('密码修改成功！');</script>");
                }
                else
                {
                    Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "changefailed", "<script type='text/javascript'>alert('密码修改失败！');</script>");
                }
                //UserType.EnterpriseUser
            }
        }
        else
        {
            Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "emptywaring1", "<script type='text/javascript'>alert('密码输入值不能为空！');</script>");
        }
    }
}
